package uy.com.pzit.fpmundialmodel.web;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;




public class ModelContextServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static ApplicationContext context;
	private static FileSystemXmlApplicationContext springContext;

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		setContext(WebApplicationContextUtils.getWebApplicationContext(getServletContext()));
	}

	/**
	 * @param context the context to set
	 */
	private static void setContext(ApplicationContext context) {
		ModelContextServlet.context = context;
	}

	/**
	 * @return the context
	 */
	public static ApplicationContext getContext() {
		return context;
	}

	
	
	
	/**
	 * @param springContext the springContext to set
	 */
	public static void setSpringContext(
			FileSystemXmlApplicationContext springContext) {
		ModelContextServlet.springContext = springContext;
	}

	/**
	 * @return the springContext
	 */
	public static FileSystemXmlApplicationContext getSpringContext() {
		return springContext;
	}
	
	
}
